<?php

/**
 * Manage some base actions
 * @author Tuong Tran <tuong.tran@outlook.com>
 */
class SiteController extends Controller {

  public $layout = 'column1';
  public $content = array();

  /**
   * Declares class-based actions.
   */
  public function actions() {
    return array(
        // captcha action renders the CAPTCHA image displayed on the contact page
        'captcha' => array(
            'class' => 'CCaptchaAction',
            'backColor' => 0xFFFFFF,
        ),
        'newsletter' => array(
            'class' => 'application.widgets.newsletter.ANewsletter'
        )
    );
  }

  /**
   * render home page
   */
  public function actionIndex() {
    //$this->description = settings()->get('seo', 'home_description');
    //$this->keywords = settings()->get('seo', 'home_keywords');
    //page title
    //$pageTitle = settings()->get('seo', 'home_title');
    //if ($pageTitle != NULL) {
    //    $this->pageTitle = $pageTitle;
    //}
    $this->layout = 'mainlayout';
    $this->render('index');
  }

  public function actionAbout() {
    $this->content['widget'] = array('application.widgets.newsletter.WSitebar', 'application.widgets.newsletter.WSuccessStory');
    $this->render('about');
  }

  public function actionRegister() {
    
    //$abc= Constant::ABC;
    if (r()->isPostRequest) {
      $userRegistration = new mRegistration();
      $userRegistration->aliasAttrFormWithModel($_POST);
      if ($userRegistration->validate() && $userRegistration->checkUniqueUsernameEmail()) {
        $userRegistration->insertUserProfile();
        Yii::app()->clientScript->registerCssFile(WWW_URL . "css/css1/essay-04-21.css");
        Yii::app()->clientScript->registerCssFile(WWW_URL . "css/css1/external_site_styles.css");
        $this->render('about_general', array('profile_id' => $userRegistration->id_profile));
        //exit();
      }else
        $this->render('register');
    } else {
      $this->content['widget'] = array('application.widgets.newsletter.WSitebarRegister');
      $this->content['addScript'] = array('registration.js');
      $this->content['addCss'] = array('profile-04-21.css');
      $this->render('register');
    }
  }

}